//
// Description: 434. 字符串中的单词数
// Created by Loading on 2021/10/7.
//

#include <bits/stdc++.h>

using namespace std;

int countSegments(string s) {
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        if ((i == 0 || s[i - 1] == ' ') && s[i] != ' ') {
            ++cnt;
        }
    }

    return cnt;
}

int main() {
    string s = "love live! music forever";
    int res = countSegments(s);
    cout << res << endl;

    return 0;
}